package com.zjzywl.smoke.service.impl;

import java.util.Date;
import java.util.List;

import org.aspectj.weaver.ast.Not;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zjzywl.smoke.config.BaseDataConfig;
import com.zjzywl.smoke.entity.Alarm;
import com.zjzywl.smoke.repository.AlarmRepository;
import com.zjzywl.smoke.service.AlarmService;
import com.zjzywl.smoke.util.NotDispose;
@Service
public class AlarmServiceImpl implements AlarmService {
	@Autowired
	private AlarmRepository repository;
	@Override
	public List<Alarm> findAll() {
		List<Alarm> alarms = repository.findAll();
		return alarms;
	}

	@Override
	public List<Alarm> findByBeginTimeBetweenOrderByBeginTime(Date bTime, Date eTime) {
		List<Alarm> alarms = repository.findByBeginTimeBetweenOrderByBeginTime(bTime, eTime);

		return alarms;
	}

	@Override
	public List<Alarm> findByBeginTimeAndDevCode(Date bTime, Date eTime, String devcode) {
		List<Alarm> alarms = repository.findByBeginTimeAndDevCode(bTime, eTime, devcode);
		return alarms;
	}

	@Override
	public List<Alarm> findByBeginTimeAndAddress(Date bTime, Date eTime, String address) {
		List<Alarm> alarms = repository.findByBeginTimeAndAddress(bTime, eTime, address);
		return alarms;
	}

	@Override
	public List<Alarm> findByBeginTimeAndDevCodeAndAlarmTypeCode(Date bTime, Date eTime, String devcode,
			String alarmTypeCode) {
		List<Alarm> alarms = repository.findByBeginTimeAndDevCodeAndAlarmTypeCode(bTime, eTime, devcode, alarmTypeCode);
		return alarms;
	}

	@Override
	public List<Alarm> findByBeginTimeAndAlarmTypeCode(Date bTime, Date eTime, String alarmTypeCode) {
		List<Alarm> alarms = repository.findByBeginTimeAndAlarmTypeCode(bTime, eTime, alarmTypeCode);
		return alarms;
	}

	@Override
	public List getDeviceAlarmCountByTime(String bTime, String eTime, int count) {
		List alarms = repository.getDeviceAlarmCountByTime(bTime, eTime, Integer.valueOf(count));
	
		return alarms;
	}

	@Override
	public List getDeviceAlarmCountByTimeEx(String bTime, String eTime, int count, String alarmTypeCode,
			String deviceTypeId, String userId) {
		List alarms = repository.getDeviceAlarmCountByTimeEx(bTime, eTime, count, alarmTypeCode,
				deviceTypeId, userId);
		return alarms;
	}


	@Override
	public List getOrgAlarmCountByTime(String bTime, String eTime, int i) {
		List alarms = repository.getOrgAlarmCountByTime(bTime, eTime, 0);
		return alarms;
	}

	@Override
	public List getOrgAlarmCountByTimeEx(String bTime, String eTime, int i, String alarmTypeCode, String deviceTypeId,
			String userId) {
		List alarms = repository.getOrgAlarmCountByTimeEx(bTime, eTime, 0, alarmTypeCode, deviceTypeId, userId);
		return alarms;
	}

	@Override
	public int findByBegin(Date bTime, Date eTime, int alarmTypeId) {
		int count = repository.findByBegin(bTime, eTime, alarmTypeId);
		return count;
	}

	@Override
	public List findByDisposeStatusAndAlarmType(int i, String alarmFire) {
		List  alarms = repository.findByDisposeStatusAndAlarmType(0, BaseDataConfig.ALARM_FIRE);
		return alarms;
	}

	

	@Override
	public Alarm findOne(int alarmId) {
		Alarm alarm = repository.findOne(alarmId);
		return alarm;
	}

	@Override
	public void save(Alarm alarm) {
		repository.save(alarm);		
	}

	@Override
	public void updateAllDisposeStatus(int disposeStatus, String name, String disposeContent) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Alarm> findByDisposeStatus(int disposeStatus) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getOrgAlarmCountByAlarmReasons(String bTime, String eTime, int i, String alarmTypeCode,
			String deviceTypeId, String userId) {
		List alarms = repository.getOrgAlarmCountByAlarmReasons(bTime, eTime, 0, alarmTypeCode, deviceTypeId, userId);
		return alarms;
	}

	@Override
	public List getDeviceAlarmCountByTime(String b, String e, Integer byCount) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getDeviceAlarmCountByTimeEx(String b, String e, Integer byCount, String alarmCode, String deviceTypeId,
			String userId) {
		List alarms = repository.getDeviceAlarmCountByTimeEx(b, e, byCount, alarmCode,
				deviceTypeId, userId);
		return alarms;
	}

	@Override
	public List getSpeciesAlarmCountByTimeEx(String bTime, String eTime, String alarmTypeCode, String fireCount,
			String userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getOrgAlarmCountByTime(String b, String e, Integer orgid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getOrgAlarmCountByTimeEx(String b, String e, Integer orgid, String alarmCode, String deviceTypeId,
			String userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getOrgAlarmCountByAlarmReasons(String b, String e, Integer orgid, String alarmCode, String deviceTypeId,
			String userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getOrgAlarmCountByAlarmReasons(String bTime, String eTime, String alarmTypeCode, String deviceTypeId,
			String userId, String alarmReasons) {
		List beforAlarms = repository.getOrgAlarmCountByAlarmReasons(bTime,
				eTime, alarmTypeCode, deviceTypeId, userId, alarmReasons);
		return beforAlarms;
	}

	@Override
	public List getOrgAlarmCountByDevice(String b, String e, Integer orgid, String alarmCode, String deviceTypeId,
			String userId) {
		List alarms = repository.getOrgAlarmCountByDevice(b, e, 0, alarmCode, deviceTypeId, userId);
		return alarms;
	}

	@Override
	public List getOrgAlarmCountByDevice(String b, String e, String alarmCode, String deviceTypeId, String userId,
			String fixedPlace) {
		List CurrAlarms = repository.getOrgAlarmCountByDevice(b,e, alarmCode, deviceTypeId, userId, fixedPlace);
		return CurrAlarms;
	}

	@Override
	public List getAlarmCountByDevice(String b, String e, Integer orgid, String alarmCode, String deviceTypeId,
			String userId, String fixedPlace) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getAlarmCount(String bTime, String eTime, String alarmTypeCode, String userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getAlarmCountByTime(String bTime, String eTime, String alarmTypeCode, String userId) {
		List alarms = repository.getAlarmCountByTime(bTime, eTime, alarmTypeCode, userId);
		return alarms;
	}

	
	@Override
	public List getByTimeAndDisposeStatusAndAlarmTypeAndUser(String currentWeekTime, String currentTime, String userId,
			Integer status, String alarmCode) {
		List<Alarm> secondCount = repository.getByTimeAndDisposeStatusAndAlarmTypeAndUser(
				currentWeekTime,currentTime, userId, status, alarmCode);		
		return secondCount;
	}

	@Override
	public List getByDisposeStatusAndAlarmType(String userId, Integer status, String alarmCode) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getAlarmByTimeAndAlarmTypeAndAddressAndUser(String bTime, String eTime, String alarmCode,
			String deviceTypeId, String address, String userId) {
		List alarms = repository.getAlarmByTimeAndAlarmTypeAndAddressAndUser(bTime, eTime, alarmCode,
				deviceTypeId, address, userId);
		return alarms;
	}

	@Override
	public List getAlarmByTimeAndAlarmTypeAndAddressAndUserSimple(String bTime, String eTime, String alarmCode,
			String deviceTypeId, String address, String userId) {
		List alarms = repository.getAlarmByTimeAndAlarmTypeAndAddressAndUserSimple(bTime, eTime, alarmCode,
				deviceTypeId, address, userId);
		return null;
	}

	@Override
	public List getAlarmByalarmTypeId(Integer userId, String alarmTypeCode) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getFixedPlaceByuser(String userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getDeviceAlarmCountByTimeEx(String bTime, String eTime, int count, int alarmTypeCode,
			String deviceTypeId, String userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List getByDisposeStatusAndAlarmTypeAndUser(String userId, Integer status, String alarmCode) {
			List<Alarm> alarms = repository.getByDisposeStatusAndAlarmTypeAndUser(userId, 0, BaseDataConfig.ALARM_FIRE);
			return alarms;
		
	}

	@Override
	public List getAlarmByTimeAndAlarmTypeAndAddressAndUserAndAlarmReasons(String beginTime, String endTime,
			String alarmTypeCode, String deviceTypeId, String address, String userId, String alarmReasons) {
		List alarms = repository.getAlarmByTimeAndAlarmTypeAndAddressAndUserAndAlarmReasons(beginTime, endTime,
				alarmTypeCode, deviceTypeId, address, userId, alarmReasons);
		return alarms;
	}

	@Override
	public List getByDisposeStatusAndAlarmTypeAndUserAndTime(String beginTime, String endTime, String userId,
			int i, String alarmFire) {
		List alarms = repository.getByDisposeStatusAndAlarmTypeAndUserAndTime(beginTime,endTime,userId, i, BaseDataConfig.ALARM_FIRE);
		return alarms;
	}
	
}
